#!/usr/bin/perl

use strict;
use Time::HiRes qw(sleep);
use HTTP::Daemon;
use HTTP::Status;

$SIG{PIPE} = sub { warn "Got SIGPIPE\n" };
my $d = HTTP::Daemon->new(LocalPort => 33008, ReuseAddr => 1, Listen => 3) || die;
print "Please contact me at: ", $d->url, "\n";
while (my $c = $d->accept) {
	while (my $r = $c->get_request) {
		warn "Got request: ".$r->method." ".$r->uri."\n";
		$c->send_basic_header;
		$c->send_crlf;
		print $c q[{"contributors":null,"in_reply_to_screen_name":null,"favorited":false,"text":"Hai people. I didn't sleep at all. Hahar. Going for paper in an hour's time. Don't want to leave him. Wish he would go cons today. :(","in_reply_to_status_id":null,"source":"<a href=\"http://twitterrific.com\" rel=\"nofollow\">Twitterrific</a>","in_reply_to_user_id":null,"user":{"lang":"en","statuses_count":294,"notifications":null,"profile_link_color":"ff00fb","location":"","following":null,"profile_background_image_url":"http://a3.twimg.com/profile_background_images/72976759/tumblr_kvspplCEbX1qavjt3o1_500.jpg","contributors_enabled":false,"geo_enabled":false,"profile_sidebar_fill_color":"3b1b57","profile_background_tile":true,"description":"","profile_sidebar_border_color":"ff0011","url":null,"verified":false,"followers_count":19,"profile_image_url":"http://a1.twimg.com/profile_images/679502236/party_dont_start_normal.jpg","friends_count":13,"profile_background_color":"642D8B","protected":false,"screen_name":"yxbiteshard","favourites_count":0,"name":"Yuanxing Tan","created_at":"Mon Jun 08 02:26:09 +0000 2009","profile_text_color":"751fff","id":45480592,"time_zone":"Singapore","utc_offset":28800},"id":9649445801,"created_at":"Thu Feb 25 23:41:55 +0000 2010","geo":null,"truncated":false}]."\n";
		warn "Send 1\n";
		sleep(1.001);
		print $c q[{"contributors":null,"in_reply_to_screen_name":null,"favorited":false,"text":"Ngapelin andi y? \u263a RT @mademoiselleina: Mariii mem-bandung....get prepared...yuukk ahhh...","in_reply_to_status_id":null,"source":"<a href=\"http://ubertwitter.com\" rel=\"nofollow\">UberTwitter</a>","in_reply_to_user_id":null,"user":{"lang":"en","statuses_count":2005,"notifications":null,"profile_link_color":"C06827","location":"\u00dcT: -6.263378,106.70825","following":null,"profile_background_image_url":"http://a1.twimg.com/profile_background_images/70164944/xa1f4f6995e57ad0d11ba1b0da33af88.png","contributors_enabled":false,"geo_enabled":true,"profile_sidebar_fill_color":"C8C8A9","profile_background_tile":true,"description":"sweet...so sweet","profile_sidebar_border_color":"83AF9B","url":"http://www.facebook.com/people/Miftah-Michew-Iip/754028470","verified":false,"followers_count":89,"profile_image_url":"http://a1.twimg.com/profile_images/544294592/michewmerah_normal.jpg","friends_count":76,"profile_background_color":"860B21","protected":false,"screen_name":"michew8284","favourites_count":1,"name":"miftah agustini","created_at":"Wed Apr 15 02:09:23 +0000 2009","profile_text_color":"790B07","id":31306506,"time_zone":"Jakarta","utc_offset":25200},"id":9649445804,"created_at":"Thu Feb 25 23:41:55 +0000 2010","geo":null,"truncated":false}]."\n";
		warn "Send 2\n";
		sleep(1.001);
		print $c q[{"contributors":null,"in_reply_to_screen_name":null,"favorited":false,"text":"I'm tweeting @alyssamariedias from the potty 'cause I told her I would!","in_reply_to_status_id":null,"source":"<a href=\"/devices\" rel=\"nofollow\">txt</a>","in_reply_to_user_id":null,"user":{"lang":"en","statuses_count":17076,"notifications":null,"profile_link_color":"b30009","location":"Wherever my heart leads me","following":null,"profile_background_image_url":"http://a3.twimg.com/profile_background_images/30568091/049.JPG","contributors_enabled":false,"geo_enabled":false,"profile_sidebar_fill_color":"DDFFCC","profile_background_tile":false,"description":"A proud member of The Bigger Lights: Street Lights. A proud Gleek. Acting is my biggest passion and my heart is searching for someone to love 3","profile_sidebar_border_color":"BDDCAD","url":"http://www.alltimechristina.tumblr.com","verified":false,"followers_count":115,"profile_image_url":"http://a3.twimg.com/profile_images/652659245/twitterProfilePhoto_normal.jpg","friends_count":179,"profile_background_color":"1d0f6b","protected":false,"screen_name":"XO_Christina_XO","favourites_count":139,"name":"Christina Abboud","created_at":"Wed Jan 14 21:01:21 +0000 2009","profile_text_color":"333333","id":18995371,"time_zone":"Quito","utc_offset":-18000},"id":9649445803,"created_at":"Thu Feb 25 23:41:55 +0000 2010","geo":null,"truncated":false}]."\n";
		warn "Send 3\n";
		sleep(5.001);
		$c->close;
		warn "Closed!\n";
	}
	$c->close;
	undef($c);
}


